package cn.com.registry;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author jiaming
 */
public class EtcdRegistryServiceFactory implements RegistryFactory {

    private static Map<String, RegistryService> registryMap = new ConcurrentHashMap<>();

    @Override
    public synchronized RegistryService getRegistry(String address) {
        RegistryService registryService = registryMap.get(address);
        if (registryService == null) {
            registryService = new EtcdRegistryService(address);
            registryMap.put(address, registryService);
        }
        return registryService;
    }

}